#pragma once

#include <cv.h>
#include <highgui.h>
#include <vector>
#include <math.h>
#include "Utils.h"
#include "Hist.h"
#include <stdlib.h>
#include "Container.h"
#include "Tracklet.h"
#include "HOG.h"
#include "CovarianceMatrix.h"
#include <limits>
#include "Hungarian.h"

using namespace std;

class Sample
{
public:
	vector<int*> positiveSmp;
	vector<int*> negativeSmp;

	Container container;

	vector<float> elem;
	vector<vector<float>> featurePool;
	vector<int> yi;
	vector<int> index; // store position of sample pair
	vector<vector<float>> strongClassifier;
	vector<float> output;
	vector<float> alpha;

	float missRate; 
	int frameGap; 
	float Pinit_term;
public:	
	Sample(float missRate, int frameGap);
	~Sample();

	//	void Init(Container t);
	void Init();
	void ComputeFeaturePool(CvRect rect1, CvRect rect2, int frame1, int frame2);
	void ComputeAppDescriptor(IplImage *img1, IplImage *img2);
	void ReSample();

	void LearningAppModel();
	void ComputeResult();
	void AssociateTracklet();
	double ComputeTrackletsPlink(int i, int j);
	float ComputeMotionAffinity(Tracklet tj, Tracklet ti);
	float ComputeTemporalAffinity(int deltaT);

	void NextProcess(int ignoreFrame);
	void NormalizeH();

private:
	int isTraversed(int keyword, vector<vector<int>> trackletGroup);
};